<style lang="less">
  @import './login.less';
</style>

<template>
  <div class="login">
    <div class="login-con">
      <Card icon="log-in" title="欢迎登录" :bordered="false">
        <div class="form-con">
          <login-form @on-success-valid="handleSubmit"></login-form>
          <div class="account-solve">
            <a @click="jumpPage('registAccount')">快速注册</a>
            <a @click="jumpPage('forgetPwd')">忘记密码</a>
          </div>

<!--          <p class="login-tip">用户名：q 密码：123</p>-->
        </div>
      </Card>
    </div>
  </div>
</template>

<script>
import LoginForm from '_c/login-form'
import { mapActions } from 'vuex'
import { initRouter } from '@/libs/router-util'

import * as API from "@/api/data";
import router from "@/router";

export default {
  components: {
    LoginForm
  },
  created() {
  },
  methods: {
    ...mapActions([
      'handleLogin',
      'getUserInfo'
    ]),
    handleSubmit (params) {
      this.handleLogin(params).then(res => {
        if (res.code==='0'){
          initRouter()
          this.$router.push({
            name: this.$config.homeName
          })
        }
      })
    },
    jumpPage(type){
      switch (type){
        case 'registAccount':
          router.replace({
            path: '/register'
          })
          break;
        case 'forgetPwd':
          this.$router.push({
            name: 'forget-password',
            params: {
              title: "注册成功",
              menuName: "登录",
              menuPath: "login",
              something: "创建了一个账户",
            }
          })
          break;

      }

      // this.$router.push({
      //   name: "register",
      //   params: { token:"123" }
      // })
    }
  }
}
</script>

<style>

</style>
